<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
	<script type="text/javascript">
		function mostraPedido(codRel) {
			window
					.open(
							"rel\\pedidovenda" + codRel + ".pdf" + "?random="
									+ Math.random(),
							"Pedido_de_Venda",
							"scrollbars=NO location=no resizable=YES Directories=no Menubar=no Status=no Toolbar=no Titlebar=no WIDTH=770 HEIGHT=400");
			return false;
		}
	</script>

</h:head>
<h:body>
	<h:form id="formListaPV">
		<div align="center" class="DivCentralizada"
			style="left: 50%; margin-left: -500px; height: 110px;">
			<div align="center"
				style="padding-left: 59px; float: left; padding-right: 24px;">
				<h:outputLabel value="#{message.pedido_emissao} De "
					styleClass="LabelFont" />
				<p:inputMask value="#{pedidoVendaTela.dataDeFiltro}" size="5"
					maxlength="8" style="font-size: 14px;" mask="99/99/99"
					required="true" requiredMessage="#{message.msg_requerido}">
				</p:inputMask>
			</div>
			<div align="center" style="float: left;">
				<h:outputLabel value=" #{message.pedido_emissao} Até "
					styleClass="LabelFont" />
				<p:inputMask value="#{pedidoVendaTela.dataAteFiltro}" size="5"
					maxlength="8" style="font-size: 14px;" mask="99/99/99"
					required="true" requiredMessage="#{message.msg_requerido}">
				</p:inputMask>
			</div>

			<div align="center"
				style="padding-left: 25px; float: left; padding-right: 24px;">
				<h:outputLabel value="#{message.label_pedido_de} "
					styleClass="LabelFont" />
				<p:inputText value="#{pedidoVendaTela.numDeFiltro}" size="4"
					maxlength="6" style="font-size: 14px;">
				</p:inputText>
			</div>
			<div align="center" style="float: left;">
				<h:outputLabel value=" #{message.label_pedido_ate} "
					styleClass="LabelFont" />
				<p:inputText value="#{pedidoVendaTela.numAteFiltro}" size="4"
					maxlength="6" style="font-size: 14px;">
				</p:inputText>
			</div>

			<div align="center"
				style="clear: both; float: left; padding-right: 3px; padding-top: 8px; margin-left: 47px;">
				<h:outputLabel value="#{message.solicita_filial}"
					styleClass="LabelFont" style="margin-left:30px;" />
			</div>
			<div align="center"
				style="float: left; padding-right: 24px; padding-top: 4px;">

				<p:selectOneRadio value="#{pedidoVendaTela.opcaoFilial}"
					style="float:left;">
					<f:selectItem itemLabel="Faturamento" itemValue="FATURAMENTO" />
					<f:selectItem itemLabel="Produção" itemValue="PRODUCAO" />
				</p:selectOneRadio>

				<p:selectOneMenu value="#{pedidoVendaTela.filialFiltro}"
					effect="fade" style="font-size: 13px;">
					<f:selectItem itemLabel="" itemValue="" />
					<f:selectItems value="#{usuario.listaEmpresas}" var="empresa"
						itemLabel="#{empresa.descricao}" itemValue="#{empresa.filial}"
						style="font-size: 13px;" />
					<p:ajax global="false" />
				</p:selectOneMenu>
			</div>

			<div align="center"
				style="clear: both; float: left; padding-right: 3px; padding-top: 8px; margin-left: 47px;">
				<h:outputLabel value="#{message.label_linha}" styleClass="LabelFont"
					style="margin-left:30px;" />
			</div>
			<div align="center"
				style="float: left; padding-right: 24px; padding-top: 4px;">
				<p:selectOneMenu value="#{pedidoVendaTela.linhaFiltro}"
					effect="fade" style="font-size: 13px;">
					<f:selectItem itemLabel="Todas" itemValue="" />
					<f:selectItem
						itemLabel="#{message.label_linha} #{message.label_leve}"
						itemValue="I1" />
					<f:selectItem
						itemLabel="#{message.label_linha} #{message.label_pesada}"
						itemValue="I2" />
				</p:selectOneMenu>
			</div>

			<div style="margin-top: 10px; margin-left: 150px; float: left;">
				<p:commandButton value="#{message.botao_filtrar}"
					icon="ui-icon-search" style="margin-left:30px; font-size: 14px;"
					update=":messages,@form,:formPedidos"
					action="#{pedidoVendaTela.filtrarPedidos}" />
			</div>
		</div>
	</h:form>
	<h:form id="formPedidos">
		<p:dataTable value="#{pedidoVendaTela.listaPedidoVenda}" var="pv"
			paginator="true" rows="10" rowsPerPageTemplate="10,15,30,50,100,200"
			paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
			emptyMessage="#{message.msg_semvalores}" style="margin-top:10px;"
			rowStyleClass="#{pv.pvAlterado ? 'fundo_amarelo' : ''}">

			<p:column style="width:4%">
				<p:rowToggler />
			</p:column>

			<p:column sortBy="#{pv.filial.filial}">
				<f:facet name="header">  
                    Fil F
            		</f:facet>
				<h:outputText value="#{pv.filial.filial}" />
			</p:column>

			<p:column sortBy="#{pv.filialProd.filial}">
				<f:facet name="header">  
                    Fil P 
            		</f:facet>
				<h:outputText value="#{pv.filialProd.filial}" />
			</p:column>

			<p:column sortBy="#{pv.numero}" filterBy="#{pv.numero}"
				styleClass="edit_coluna_filtro">
				<f:facet name="header">  
                    #{message.solicita_numero} 
            		</f:facet>
				<p:commandLink
					actionListener="#{pedidoVendaTela.imprimePedidoVenda(pv)}"
					rendered="#{usuario.setor.equals('Comercial')}" value="#{pv.numero}"
					oncomplete="mostraPedido('#{usuario.codigo}#{pv.numero}');" />
				<h:outputText value="#{pv.numero}"
					rendered="#{!usuario.setor.equals('Comercial')}" />
			</p:column>

			<p:column>
				<f:facet name="header">  
                    ST 
            		</f:facet>
				<h:outputText value="#{''.equals(pv.notaFiscal) ? 'A' : 'F'}" />
			</p:column>

			<p:column sortBy="#{pv.cliente.nome}" filterBy="#{pv.cliente.nome}"
				filterMatchMode="contains" styleClass="edit_coluna_filtro">
				<f:facet name="header">  
                    #{message.label_cliente} 
            		</f:facet>
				<h:outputText value="#{pv.cliente.nome}" />
			</p:column>

			<p:column sortBy="#{pv.representante.nome}"
				filterBy="#{pv.representante.nome}" filterMatchMode="contains"
				styleClass="edit_coluna_filtro">
				<f:facet name="header">  
                    #{message.label_representante} 
            		</f:facet>
				<h:outputText value="#{pv.representante.nome}" />
			</p:column>

			<p:column sortBy="#{pv.itemPedido[0].produto.codigoProjeto}"
				filterBy="#{pv.itemPedido[0].produto.codigoProjeto}"
				filterMatchMode="contains" styleClass="edit_coluna_filtro">
				<f:facet name="header">  
                    #{message.label_projeto} 
            		</f:facet>
				<h:outputText id="codPrj"
					value="#{pv.itemPedido[0].produto.codigoProjeto}" />
				<p:tooltip for="codPrj"
					value="#{pv.itemPedido[0].produto.descricao}" />
			</p:column>


			<!-- 	<p:column sortBy="#{pv.itemPedido[0].produto.descricao}"
				filterBy="#{pv.itemPedido[0].produto.descricao}"
				styleClass="edit_coluna_filtro">
				<f:facet name="header">  
                    #{message.produto_descricao} 
            		</f:facet>
				<h:outputText value="#{pv.itemPedido[0].produto.descricao}" />
			</p:column>
 -->
			<p:column sortBy="#{pv.status}" filterBy="#{pv.status}"
				styleClass="edit_coluna_filtro">
				<f:facet name="header">  
                    #{message.solicita_status} 
            		</f:facet>
				<h:outputText value="#{pv.status}" />
			</p:column>

			<p:column sortBy="#{pv.dataEntrega}">
				<f:facet name="header">  
                    #{message.label_dt_comercial} 
            		</f:facet>
				<h:outputText value="#{pv.dataEntrega}">
					<f:convertDateTime pattern="dd/MM/yy" />
				</h:outputText>
			</p:column>

			<p:column sortBy="#{pv.dataEmissao}">
				<f:facet name="header">  
                    #{message.pedido_emissao} 
            		</f:facet>
				<h:outputText value="#{pv.dataEmissao}">
					<f:convertDateTime pattern="dd/MM/yy" />
				</h:outputText>
			</p:column>

			<p:column>
				<f:facet name="header">  
                    #{message.label_dt_programacao} 
            		</f:facet>
				<h:outputText value="#{pv.dataProgramacao}">
					<f:convertDateTime pattern="dd/MM/yy" />
				</h:outputText>
			</p:column>

			<p:column sortBy="#{pv.itemPedido[0].produto.grupo}">
				<f:facet name="header">  
                    #{message.msg_grupo} 
            		</f:facet>
				<h:outputText value="#{pv.itemPedido[0].produto.grupo}" />
			</p:column>


			<p:column sortBy="#{pv.ordemProd.numero}"
				filterBy="#{pv.ordemProd.numero}" styleClass="edit_coluna_filtro">
				<f:facet name="header">  
                    #{message.produto_op}
            		</f:facet>
				<h:outputText
					value="#{pv.ordemProd.numero}#{pv.ordemProd.item}#{pv.ordemProd.sequencia}" />
			</p:column>

			<p:column>
				<f:facet name="header">  
                    ST 
            		</f:facet>
				<h:outputText value="#{pv.ordemProd.dataFim != null ? 'F' : 'A'}" />
			</p:column>


			<p:rowExpansion>

				<f:event listener="#{pedidoVendaTela.atualizaExpansion(pv)}"
					type="preRenderComponent">
				</f:event>

				<h:outputText id="gradeAc" escape="false"
					value="#{pedidoVendaTela.htmlExpansion}" />


			</p:rowExpansion>

		</p:dataTable>

	</h:form>



</h:body>
</html>